﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_58_LengthOfTheLastWord
{
    class MainProject
    {
        static void Main(string[] args)
        {
            //string str = "HelloWorld";
            //string str = "   fly me   to   the moon  ";
            //string str = "luffy is still joyboy";   
            string str = "";
            Console.WriteLine(LengthOfLastWord(str));
            Console.ReadKey();
        }

        public static int LengthOfLastWord(string s)
        {
            string[] strs = s.Split(' ');
            for (int i = strs.Length-1; i >= 0; i--)
            {
                if (strs[i] != "")
                {
                    return strs[i].Length;
                }
            }
            return 0;
        }
    }
}
